<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ page import="com.fick.hibernate.model.*"%>
<%@ page import="com.fick.hibernate.dao.*"%>
<%@page import="com.fick.tools.SystemLogger"%>
<%@ include file="../tld/tlds.jsp"%>
<%
   Admin admins = (Admin)request.getSession().getAttribute("admin");
 %>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>河南省公安厅</title>
<link href="images/jiahao.css" rel="stylesheet" type="text/css">
<script language="JavaScript" src="js/meihuaxue.js"></script>
<script language="javaScript" src="js/prototype.js"></script>
<script type="text/javascript" src="js/submit.js"></script>

</head>

<body>
<% 
			String jid = request.getParameter("jid");
			String jcid = request.getParameter("jcid");
			String hql = "";
			
			CandidateDAO canDAO = new CandidateDAO();
			
			if(jid != null && !jid.equals(""))
			{
				hql = " where job.id='"+jid+"'";
			}else
			{
				jid = "";
			}
			
			if(jcid != null && !jcid.equals(""))
			{
				JobDAO jobDAO = new JobDAO();
				Job jcjob = new Job();
				List jli = jobDAO.getSession().createQuery("from Job where jobclass.jcid = '"+jcid+"'").list();
				if(jli!=null&&jli.size()>0)
				{
					hql = " where job.id in(";
				}
				for( int j = 0 ; j < jli.size() ; j++ )
				{
					jcjob = (Job)jli.get(j);
					hql+=jcjob.getJid()+",";
					
				}
				if(jli!=null&&jli.size()>0)
				{
					hql = hql.substring(0,hql.length()-1)+") ";
				}else
				{
					hql = " where job.id in(0)";
				}
				
			}
			else
			{
				jcid = "";
			}
			
			 //当前页面
			int currPage = 1;
			//总的页数
			int totalPage = 1;
			//一个页面可显示的记录数
			int pageSize = 20;
			//总共有的记录数
			Integer totalCount = 1;
			totalCount = (Integer)canDAO.getSession().createQuery("select count(*) from Candidate " + hql).uniqueResult();
		
			//得到总的页数
			if(totalCount > pageSize){
			   totalPage = totalCount/pageSize+1;
			   }else{
			   totalPage = 1;
			   }
			Admin admin = new Admin();
			//判断是否是传过来页数
			if(request.getParameter("currPage") != null){
			   currPage = Integer.parseInt(request.getParameter("currPage"));
			   if(currPage<1){
			     currPage=1;
			    }
			   if(currPage >totalPage){
			     currPage = totalPage;
			   }
			} 
			//得到记录数
			
			List  li = canDAO.findPageByHql(hql,currPage,pageSize);
		 %>
<table width="100%"  height="100%"  border="0" cellspacing="0" cellpadding="0">
  <tr>
    <td height="100%" align="center" valign="top" background="images/main_bj.gif" bgcolor="#FBFCFD">



    
      <table width="98%" border="0" cellpadding="0" cellspacing="1" bgcolor="#D7DFE1">
        <tr>
          <td width="8%" height="25" align="center" valign="middle" background="images/main_t_bj.gif" bgcolor="#FFFFFF" class="ts_lmdh">选择</td>
          <td width="11%" height="25" align="center" valign="middle" background="images/main_t_bj.gif" bgcolor="#FFFFFF" class="ts_lmdh">姓名</td>
          <td width="52%" height="25" align="center" valign="middle" background="images/main_t_bj.gif" bgcolor="#FFFFFF" class="ts_lmdh">应聘职位</td>
          <td width="17%" height="25" align="center" valign="middle" background="images/main_t_bj.gif" bgcolor="#FFFFFF" class="ts_lmdh">提交时间</td>
          <td width="12%" height="25" align="center" valign="middle" background="images/main_t_bj.gif" bgcolor="#FFFFFF" class="ts_lmdh">操作</td>
        </tr>
       <% 
		for( int i = 0 ; i<li.size();i++ )
		{
			Candidate temp = (Candidate)li.get(i);
			%>
		<tr>
          <td width="8%" height="25" align="center" valign="middle" bgcolor="#FFFFFF">
		 <input type="checkbox" name="MyCheckBox" id="MyCheckBox" value="<%=temp.getCid()%>" />
		  </td>
          <td width="11%" height="25" align="left" valign="middle" bgcolor="#FFFFFF" style="padding-left:7px">
		  <a href="candet.jsp?cid=<%=temp.getCid()%>" target="blank"><%=temp.getName() %></a>
		  </td>
          <td width="52%" height="25" align="center" valign="middle" bgcolor="#FFFFFF">
		  <% 
			if(jid != null && !jid.equals(""))
			{
				out.print((new JobDAO().findById(Integer.valueOf(jid))).getJname());	
			}else
			{
				out.print((new JobDAO().findById(temp.getJob().getJid())).getJname());
			}
		%>
		  </td>
          <td width="17%" height="25" align="center" valign="middle" bgcolor="#FFFFFF">
		  <%=temp.getAddtime().toString().substring(0,10) %></td>
          <td width="12%" height="25" align="center" valign="middle" bgcolor="#FFFFFF">
		<a href="candet.jsp?cid=<%=temp.getCid()%>" target="blank">详情</a>&nbsp;&nbsp;<a href="<%=request.getContextPath()%>/admin/managerCandidate.do?method=delCan&cid=<%=temp.getCid()%>">删除</a></td>
        </tr>
		<%
			}
		%>
		
	
        
		
      </table>
	    <table width="98%" border="0" cellspacing="0" cellpadding="0">
	  	<tr>
			 <td height="45" align="left" valign="middle">
				 <input type="button" name="selectAlls" id="selectAlls" value="全选" onclick="return selectAll()" />
				  <input type="button" name="noSelectAll" id="noSelectAll" value="反选" onclick="return selectOthers();" />
				   <input type="button" name="cancelSelects" id="cancelSelects" value="取消选择" onclick="return cancelSelect();" />
				  <input type="button" name="delAlls" id="delAlls" value="全部删除" onclick="return delAllCan();"/>
										   	  	
			</td>
		</tr>
	  </table>
      <table width="98%" border="0" cellspacing="0" cellpadding="0">
        <tr>
          <td height="45" align="center" valign="middle">
		  共有［<%=totalPage %>］页 当前是第［<%=currPage %>］页 [
			<a href="canTree.jsp?currPage=1&jid=<%=jid %>&jcid=<%=jcid %>" class="page">首页</a>][
			<a href="canTree.jsp?currPage=<%=currPage-1 %>&jid=<%=jid %>&jcid=<%=jcid %>"
				class="page">上一页</a>][
			<a href="canTree.jsp?currPage=<%=currPage+1 %>&jid=<%=jid %>&jcid=<%=jcid %>"
				class="page">下一页</a>][
			<a href="canTree.jsp?currPage=<%=totalPage %>&jid=<%=jid %>&jcid=<%=jcid %>"
				class="page">尾页</a>]
			<input type="button" value="GO" onclick="isDigit()" />
			<input type="text" size="1" name="currPage" id="currPage"/>			
		 </td>
        </tr>
      </table>
</table>
</body>
</html>
<script type="text/javascript">
		function isDigit(s) 
		{ 
			     
			     var currPage = document.getElementById("currPage").value;
			     var patrn=/^[0-9]{1,20}$/; 
			      if (!patrn.exec(currPage)){
				    alert("请输入数字");
			        return false ;
					}else{
                       location="canTree.jsp?currPage="+currPage+"&jid=<%=jid %>";
		          }
		}

</script>
<script type="text/javascript">
<!--
var message = "<%=request.getAttribute("message")%>";
if(message!=null && message!="null" && message !=""){
   alert(message);
  }
//-->
</script>
<%
	request.removeAttribute("message");
%>

